/**
 * 功能描述 
 */

define(function (require, exports, module) {
	var Grid = require("grid");	
	var contractStat = require("../store/contractStat");
	var store =require("store");				
		
    var instance = {
        initComponent: function (params,widget) {
        	var grid = new Grid({
        		parentNode:".J-grid",
        		autoRender : false,
        		url:"api/travelcontract/queryCount",
        		params:function(){
        			var subnav = widget.get("subnav");
        			var obj = {
                			"signUpDate" : subnav.getValue("signUpDate").start,
                			"signUpDateEnd" : subnav.getValue("signUpDate").end,        					
                			fetchProperties:"pkProduct,pkProductType,productName,productType,contractCount,allMoney,signUpDate"
        			};
        			return obj;
        			alert(""+obj)
        		},
        		model:{
        			columns:[{
        				name:"productName",
        				label:"产品",
        			},
        			{
        				name:"productType",
        				label:"产品类型",
        			},
        			{
        				name:"contractCount",
        				label:"签约数量",
        			    format:"detail",
        			    formatparams: {
        			    	key:"detail",
        			    	handler:function(index,data,rowEle){
//        			    		console.log(data.signUpDate);
        			    		widget.hide([".J-grid"]).show([".J-countgrid"]);
        			    		widget.get("subnav").hide(["signUpDate"]).show(["return"]);
        			    		var subnav = widget.get("subnav");
        			    		widget.get("countgrid").refresh({
        			    			
        			    			pkProduct:data.pkProduct,
            			    		pkProductType:data.pkProductType,
            			    		"signUpDate" : subnav.getValue("signUpDate").start,
            			    		"signUpDateEnd" : subnav.getValue("signUpDate").end,	    		
            			    		fetchProperties:"contractNo,memberName,memberSex,phone,productName,productTypeName,number,singUpDate,allPay"
        			    		});

        			    	}
        			    }
        			},
        			{
        				name:"allMoney",
        				label:"总金额(元)",
        				format:function(val){
        					return Number(val).toFixed(2);
        				}
        			}]
        			
        		}
        	});  
        	widget.set("grid",grid);
        }
    };
    module.exports = instance;
});
